package com.xiaolun.controller;

import com.xiaolun.mapper.OrderMapper;
import com.xiaolun.pojo.Order;
import com.xiaolun.util.LayuiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class OrderList {

    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping(value = "/list",method = RequestMethod.GET)
    @ResponseBody
    public Object listShow(@RequestParam("page") int page,@RequestParam("limit") int limit) {
        List<Order> orderList = this.orderMapper.findOrderPage((page - 1) * limit,limit);
        List<Order>  orderTotalList = this.orderMapper.findAll(); //返回数据总条数
        return new LayuiResponse(0, "请求成功", orderList, orderTotalList.size());
    }
}
